package main

import (
    "html/template"
    "log"
    "os"
    "fmt"
)

/*************************************************
 According to the documentation, you can call any method 
 which returns one value (of any type) or two values 
if the second one is of type error.
In the later case, Execute will return that error if it is non-nil 
and stop the execution of the template.
************************************************/

type Person string

func (p Person) Label() string {
    return "This is " + string(p)
}

func printStr(val string) string {
    fmt.Println("printStr,%s")
    return val
}

func main() {
    tmpl, err := template.New("").Parse("{{.Label}} {{.printStr(`aaaa`) }}")
    if err != nil {
        log.Fatalf("Parse: %v", err)
    }
    tmpl.Execute(os.Stdout, Person("Bob"))
}
